package com.jiang.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
@Aspect
public class AopAspect  {

    @Pointcut("execution(public * com.jiang.service.AAA.*(..))")
    public void point(){

    }
    @Around("point()")
    public Object around(ProceedingJoinPoint p) throws Throwable {
        Signature sig = p.getSignature();
        MethodSignature methodSignature = (MethodSignature) sig;
        Method method = methodSignature.getMethod();
        System.out.println("前置逻辑");
        Object r=p.proceed();
        System.out.println("执行方法："+method.getName());
        //代理
        return r;
    }
}